/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package e.odbo.data.dao;

import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.serialize.DataRead;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.serialize.serializer.SerializerRead;
import e.odbo.data.dsl.query.QBFParameter;
import e.odbo.data.dsl.query.QBFParameters;
import e.odbo.data.dsl.operation.QueryOperation;
import e.odbo.data.sample.security.I_SecurityFilter;
import e.odbo.data.dsl.Select;
import e.odbo.data.service.base.I_ViewBeanService;

import java.util.List;

/**
 * @author Administrator
 */
public abstract class ViewDAO<T> implements SerializerRead<T> {
    protected I_Session s;

    I_SecurityFilter filter;

    public ViewDAO(I_Session s) {
        this.s = s;
    }

    public ViewDAO(I_Session s, I_SecurityFilter filter) {
        this.s = s;
        this.filter = filter;
    }

    public List<T> list() throws BasicException {
        return list(null);
    }

    public abstract Class getSuportClass();


    public List<T> query(QBFParameter filter) throws BasicException {
        return query(new QBFParameters(filter));
    }


    public List<T> query(QBFParameter filter,QueryOperation queryOperation) throws BasicException {
        return query(new QBFParameters(filter),queryOperation);
    }

    @Override
    public T readValues(DataRead dr) throws BasicException {
        return readValues(dr, null);
    }

    public abstract T readValues(DataRead dr, T obj) throws BasicException;


    public void setSecurityFilter(I_SecurityFilter filter){
        this.filter=filter;
    }


    public List<T> list(QueryOperation queryOperation) throws BasicException {
        throw new BasicException("not supported in this ViewDAO");
    }


    public List<T> query(QBFParameters qbfParameters) throws BasicException {
        throw new BasicException("not supported in this ViewDAO");
    }

    public List<T> query(QBFParameters qbfParameters, QueryOperation queryOperation) throws BasicException {
        throw new BasicException("not supported in this ViewDAO");
    }

    public List<T> listBySelect(Select select)throws BasicException {
        throw new BasicException("not supported in this ViewDAO");
    }

    public int count()throws BasicException{
        throw new BasicException("not supported in this ViewDAO");
    }

    public int count(QBFParameters filter) throws BasicException {
        throw new BasicException("not supported in this ViewDAO");
    }
}
